<?php
/**
 * User: Jerry
 * Date: 2017/6/6
 * Time: 15:34
 */

namespace SDXApi\Model;


use Think\Model;

/**
 * Class CommunityCatModel
 * @author Jerry
 * @package SDXApi\Model
 */
class CommunityCatModel extends Model
{
    /**
     * @var string
     */
    protected $tableName = 'community_cat';

    /**
     * 获取分类总数
     * @author Jerry
     * @param int $catId
     * @return mixed
     */
    public function getCommunityCatCountByCatId($catId = 0)
    {
        $where = array(
            'parent_id' =>  $catId,
        );

        return $this->where($where)->count();
    }

    /**
     * 获取分类数据
     * @author Jerry
     * @param int $catId
     * @return mixed
     */
    public function findCommunityListCatByCatId($catId = 0)
    {
        $where = array(
            'parent_id' =>  $catId,
        );

        $field = 'cat_id';

        return $this->field($field)->where($where)->select();
    }
}